package demo06;

public class zuoye24 {
	public static void main(String[] args) {
        int count = 0; 

        for (int i = 1; i <= 1000; i++) {
            if (isPrime(i) && isPalindrome(i)) { 
                System.out.print(i + " "); 
                count++; 

                if (count % 10 == 0) {
                    System.out.println();
                }
            }
        }
    }

    public static boolean isPrime(int number) {
        if (number < 2) {
            return false; 
        }
        for (int i = 2; i <= Math.sqrt(number); i++) {
            if (number % i == 0) {
                return false; 
            }
        }
        return true; 
    }

    public static boolean isPalindrome(int number) {
        String str = Integer.toString(number); 
        int left = 0;
        int right = str.length() - 1;

        while (left < right) {
            if (str.charAt(left) != str.charAt(right)) {
                return false;
            }
            left++;
            right--;
        }
        return true; 
    }

}
